<!DOCTYPE html>
<html>
<head>
<title>Nuclear Decay Equation</title>
<style>
  body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
  }
  canvas {
    background-color: white;
    border: 1px solid #ccc;
  }
</style>
</head>
<body>
<canvas id="nuclearDecayCanvas" width="850" height="300"></canvas>
<script>
  const canvas = document.getElementById('nuclearDecayCanvas');
  const ctx = canvas.getContext('2d');

  // Set a white background
  ctx.fillStyle = 'white';
  ctx.fillRect(0, 0, canvas.width, canvas.height);

  // General drawing settings
  ctx.fillStyle = 'black';
  ctx.textAlign = 'left';
  ctx.textBaseline = 'middle';

  const mainSize = 60;
  const scriptSize = 40;
  
  // Based on the image, element symbols and alpha are serif, while numbers and operators are sans-serif.
  const symbolFont = `${mainSize}px serif`;
  const numberFont = `${scriptSize}px sans-serif`;
  const operatorFont = `${mainSize}px sans-serif`;

  const baseY = canvas.height / 2;
  const yOffset = mainSize * 0.6; // Vertical offset for superscripts and subscripts
  let currentX = 50;

  // --- 1. Polonium-211 ---
  // Draw scripts (211, 84)
  ctx.font = numberFont;
  ctx.fillText('211', currentX, baseY - yOffset);
  ctx.fillText('84', currentX, baseY + yOffset);
  const scriptWidthPo = Math.max(ctx.measureText('211').width, ctx.measureText('84').width);
  
  // Draw Symbol (Po)
  currentX += scriptWidthPo + 10; // Add padding
  ctx.font = symbolFont;
  ctx.fillText('Po', currentX, baseY);
  currentX += ctx.measureText('Po').width;
  
  // --- 2. Arrow ---
  currentX += 50; // Space before arrow
  ctx.font = operatorFont;
  ctx.fillText('→', currentX, baseY);
  currentX += ctx.measureText('→').width;

  // --- 3. Lead (Pb) with placeholders ---
  currentX += 50; // Space after arrow
  const placeholderDots = '........';
  const startXPb = currentX;

  // Draw placeholder dots
  ctx.font = numberFont;
  ctx.fillText(placeholderDots, startXPb, baseY - yOffset);
  ctx.fillText(placeholderDots, startXPb, baseY + yOffset);
  const dotsWidth = ctx.measureText(placeholderDots).width;
  
  // Draw Symbol (Pb)
  currentX += dotsWidth + 10; // Padding
  ctx.font = symbolFont;
  ctx.fillText('Pb', currentX, baseY);
  currentX += ctx.measureText('Pb').width;

  // --- 4. Plus sign ---
  currentX += 50; // Space
  ctx.font = operatorFont;
  ctx.fillText('+', currentX, baseY);
  currentX += ctx.measureText('+').width;

  // --- 5. Alpha particle with placeholders ---
  currentX += 50; // Space
  const startXAlpha = currentX;
  
  // Draw placeholder dots
  ctx.font = numberFont;
  ctx.fillText(placeholderDots, startXAlpha, baseY - yOffset);
  ctx.fillText(placeholderDots, startXAlpha, baseY + yOffset);
  
  // Draw Symbol (α)
  currentX += dotsWidth + 10; // Padding
  ctx.font = symbolFont;
  ctx.fillText('α', currentX, baseY);

</script>
</body>
</html>